import comm.InputTask;
import comm.OutputTask;
import gui.ClientWindow;
import structures.City;

import java.io.*;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: dna
 * Date: 27.04.13
 * Time: 14:19
 */
public class WeatherWebServiceClient {

    public static void main(String[] args) {

        Map<String, City> cities = new HashMap<String, City>();

        try {
            ClientWindow gui = new ClientWindow(cities);

            // Update gui with info from the server
            InputTask inputTask = new InputTask(cities,new URL("http://localhost:9998/WeatherWebService/data"),gui);
            // Update server with action from the gui
            OutputTask outputTask = new OutputTask(new URL("http://localhost:9998/WeatherWebService/set"));

            // connect gui with output thread
            gui.setOutputTask(outputTask);
            // connect output thread with gui
            inputTask.setCw(gui);

            // show window
            gui.setVisible(true);

        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
